package com.centit.framework.ip.businessdata.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.centit.framework.ip.businessdata.dao.InterfaceMethodDao;
import com.centit.framework.ip.businessdata.po.InterfaceMethod;
import com.centit.framework.ip.businessdata.service.InterfaceMethodManager;
import com.centit.framework.jdbc.service.BaseEntityManagerImpl;
import com.centit.support.database.utils.PageDesc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * InterfaceMethod  Service.
 * create by scaffold 2018-05-22
 *
 * @author guo_jh
 * T_INTERFACE_METHOD业务系统方法配置信息表
 */
@Service
public class InterfaceMethodManagerImpl
        extends BaseEntityManagerImpl<InterfaceMethod, String, InterfaceMethodDao>
        implements InterfaceMethodManager {

    public static final Log log = LogFactory.getLog(InterfaceMethodManager.class);


    private InterfaceMethodDao interfaceMethodDao;

    @Resource(name = "interfaceMethodDao")
    @NotNull
    public void setInterfaceMethodDao(InterfaceMethodDao baseDao) {
        this.interfaceMethodDao = baseDao;
        setBaseDao(this.interfaceMethodDao);
    }

    /**
     * 获取接口信息集合
     *
     * @param filterMap
     * @param pageDesc
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public JSONArray listObjectsAsJsonArray(Map<String, Object> filterMap, PageDesc pageDesc) {
        return this.interfaceMethodDao.listObjectsAsJsonArray(filterMap, pageDesc);
    }

    /**
     * 获取接口信息集合
     *
     * @param filterMap
     * @param pageDesc
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public JSONArray listObjectsAsJson(Map<String, Object> filterMap, PageDesc pageDesc) {
        return this.interfaceMethodDao.listObjectsAsJson(filterMap, pageDesc);
    }

    /**
     * 根据系统ID删除系统所属接口
     *
     * @param recordid 系统ID
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public boolean deleteObjectByRecordId(String recordid) {
        return this.interfaceMethodDao.deleteObjectByRecordId(recordid);
    }


}

